﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Collections.Generic;
using HRProject.Code.Common;

namespace HRProject.Component
{
    public partial class Tab : System.Web.UI.UserControl
    {
        private List<TabItem> tabList1;
        private List<TabItem> tabList2;
        private string selectedTab1;
        private string selectedTab2;

        public List<TabItem> TabList1
        {
            get { return tabList1; }
        }

        public List<TabItem> TabList2
        {
            get { return tabList2; }
        }

        public string SelectedTab1
        {
            get { return selectedTab1; }
        }

        public string SelectedTab2
        {
            get { return selectedTab2; }
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            selectedTab1 = (string)Page.Items["tab_navigation_1"];
            if (selectedTab1 == null)
            {
                selectedTab1 = "worktime";
            }
            selectedTab2 = (string)Page.Items["tab_navigation_2"];
            if (selectedTab2 == null)
            {
                selectedTab2 = "dailyworktime";
            }

            tabList1 = new List<TabItem>();
            tabList1.Add(new TabItem("worktime", ContentProvider.GetString("Worktime"), "/Worktime/ManageWorktime2.aspx"));
            tabList1.Add(new TabItem("overworktime", ContentProvider.GetString("OverWorktime"), "/Worktime/ManageWorktime4.aspx"));
            tabList1.Add(new TabItem("basicsalary", ContentProvider.GetString("BasicSalary"), "/Salary/BasicSalary.aspx"));
            tabList1.Add(new TabItem("responsiblesalary", ContentProvider.GetString("ResponsibleSalary"), "/Salary/ResponsibleSalary.aspx"));
            tabList1.Add(new TabItem("houseallowance", ContentProvider.GetString("HouseAllowance"), "/Salary/HouseAllowance.aspx"));

            tabList2 = new List<TabItem>();
            if ("worktime".Equals(selectedTab1))
            {
                tabList2.Add(new TabItem("dailyworktime", ContentProvider.GetString("DailyWorktime"), "/Worktime/ManageWorktime2.aspx"));
                tabList2.Add(new TabItem("monthlyworktime", ContentProvider.GetString("MonthlyWorktime"), "/Worktime/ManageWorktime3.aspx"));
            }
            else if ("overworktime".Equals(selectedTab1))
            {
                tabList2.Add(new TabItem("dailyoverworktime", ContentProvider.GetString("DailyOverWorktime"), "/Worktime/ManageWorktime4.aspx"));
                tabList2.Add(new TabItem("monthlyoverworktime", ContentProvider.GetString("MonthlyOverWorktime"), "/Worktime/ManageWorktime5.aspx"));
            }
        }
    }

    public class TabItem
    {
        private string key;
        private string label;
        private string url;

        public string Url
        {
            get { return url; }
            set { url = value; }
        }

        public string Label
        {
            get { return label; }
            set { label = value; }
        }

        public string Key
        {
            get { return key; }
            set { key = value; }
        }

        public TabItem(string key, string label, string url)
        {
            this.key = key;
            this.label = label;
            this.url = url;
        }
    }
}